package org.iabako.shared.iservice.business;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import org.iabako.shared.entity.business.Installment;
import org.iabako.shared.entity.business.Payment;
import org.iabako.shared.entity.business.Sale;
import org.iabako.shared.entity.business.SaleProductService;
import org.iabako.shared.exception.IabakoActionForbiddenException;
import org.iabako.shared.exception.IabakoPackageForbiddenException;
import org.iabako.shared.exception.IabakoStockException;
import org.iabako.shared.exception.IabakoUniqueConstraintException;
import org.iabako.shared.iservice.generic.BusinessEntityService;
import org.iabako.shared.iservice.generic.CRUDService;
import org.iabako.shared.iservice.generic.SearchService;

import java.util.List;

/**
 * Created by jose on 26/08/14.
 */

@RemoteServiceRelativePath("iabakoServices/saleService")
public interface SaleService extends SearchService, CRUDService, BusinessEntityService, RemoteService {

    Sale save(boolean isDraft, Sale sale, List<SaleProductService> productsServices, List<Payment> payments, List<Installment> installments)
            throws IabakoActionForbiddenException, IabakoPackageForbiddenException, IabakoUniqueConstraintException, IabakoStockException;

    Sale save(Sale sale) throws IabakoActionForbiddenException, IabakoUniqueConstraintException;

    Sale rawSave(Sale sale);

    List<Payment> getPayments(Sale sale);

    List<Installment> getInstallments(Sale sale);

    Sale calculateStatusAndSave(Sale sale, boolean isDraft);

    void paymentToInstallment(Long idPayment);

    void installmentToPayment(Installment installment) throws IabakoPackageForbiddenException;

    List<Installment> getCustomInstallmentsDefinition(Sale sale);

    List<SaleProductService> getProductServiceList(Sale sale);

    Sale stopUndefinedInstallmentsCreation(Sale sale) throws IabakoActionForbiddenException;

    void addProductsServicesToSale(boolean isDraft, Sale saleFromDB, List<SaleProductService> productsServices) throws IabakoStockException;
}
